package cocurrency.atomic;

import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by luzl on 4/7/2017.
 */
public class Main {
    public static void main(String args[]){
        AtomicInteger count=new AtomicInteger(0);
        CyclicBarrier cyclicBarrier=new CyclicBarrier(10000);
        for (int i=0;i<10000;i++){
            AtomicThread thread=new AtomicThread(cyclicBarrier,count,"Seq"+i);
            thread.start();
        }
        while(Thread.activeCount()>2){
            System.out.println(Thread.activeCount());
            Thread.currentThread().yield();
        }
        System.out.println("Result: "+ AtomicThread.count);
    }
}
